package acceptanceTest;

import java.math.BigDecimal;
import java.util.List;

import com.acmetelecom.customer.CentralCustomerDatabase;
import com.acmetelecom.customer.CentralTariffDatabase;
import com.acmetelecom.customer.Customer;
import com.acmetelecom.customer.Tariff;

public class PhoneRate {

	private static List<Customer> customers;
	private Customer customer;
	private Tariff tariff;
	public PhoneRate(){
		 customers = CentralCustomerDatabase.getInstance().getCustomers();
	}
	
	public void setCustomer(String customer) throws Exception {
		for(Customer c:customers)
			if(c.getFullName().equals(customer))
				this.customer = c;
		tariff = CentralTariffDatabase.getInstance().tarriffFor(this.customer);
	}

	public void setUp() throws Exception {
		//Put the code to be executed before execution of each row
	}

	public void tearDown() throws Exception {
		//Put the code to be executed after execution of each row
	}

	public String pricePlan() throws Exception {
		return customer.getPricePlan();
	}

	public String peakRate() throws Exception {
		return tariff.peakRate().setScale(2, BigDecimal.ROUND_HALF_UP).toString();
	}

	public String offPeakRate() throws Exception {
		return tariff.offPeakRate().setScale(2, BigDecimal.ROUND_HALF_UP).toString();
	}

}